package com.demo.common.core.exception;

/**
 * 自定义的异常服务统一自定义异常类型
 * @author zh-ma
 * @since 2019/07/04
 */
public class AppException extends RuntimeException {
    /**
     * 异常对应的错误类型
     */
    private final ErrorType errorType;

    /**
     * 默认是系统异常
     */
    public AppException() {
        this.errorType = SystemErrorType.SERVICE_ERROR;
    }

    public AppException(String message) {
        super(message);
        this.errorType = SystemErrorType.SERVICE_ERROR;
    }

    public AppException(ErrorType errorType) {
        this.errorType = errorType;
    }

    public AppException(ErrorType errorType, String message) {
        super(message);
        this.errorType = errorType;
    }

    public AppException(ErrorType errorType, String message, Throwable cause) {
        super(message, cause);
        this.errorType = errorType;
    }

    public ErrorType getErrorType() {
        return errorType;
    }
}
    